package com.ruoyi.teach.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teach.domain.NbCourseGrade;
import com.ruoyi.teach.service.INbCourseGradeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课程评分Controller
 * 
 * @author ruoyi
 * @date 2021-12-08
 */
@RestController
@RequestMapping("/teach/course_grade")
public class NbCourseGradeController extends BaseController
{
    @Autowired
    private INbCourseGradeService nbCourseGradeService;

    /**
     * 查询课程评分列表
     */
    @PreAuthorize("@ss.hasPermi('teach:course_grade:list')")
    @GetMapping("/list")
    public TableDataInfo list(NbCourseGrade nbCourseGrade)
    {
        startPage();
        List<NbCourseGrade> list = nbCourseGradeService.selectNbCourseGradeList(nbCourseGrade);
        return getDataTable(list);
    }

    /**
     * 导出课程评分列表
     */
    @PreAuthorize("@ss.hasPermi('teach:course_grade:export')")
    @Log(title = "课程评分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NbCourseGrade nbCourseGrade)
    {
        List<NbCourseGrade> list = nbCourseGradeService.selectNbCourseGradeList(nbCourseGrade);
        ExcelUtil<NbCourseGrade> util = new ExcelUtil<NbCourseGrade>(NbCourseGrade.class);
        util.exportExcel(response, list, "课程评分数据");
    }

    /**
     * 获取课程评分详细信息
     */
    @PreAuthorize("@ss.hasPermi('teach:course_grade:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(nbCourseGradeService.selectNbCourseGradeById(id));
    }

    /**
     * 新增课程评分
     */
    @PreAuthorize("@ss.hasPermi('teach:course_grade:add')")
    @Log(title = "课程评分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NbCourseGrade nbCourseGrade)
    {
        return toAjax(nbCourseGradeService.insertNbCourseGrade(nbCourseGrade));
    }

    /**
     * 修改课程评分
     */
    @PreAuthorize("@ss.hasPermi('teach:course_grade:edit')")
    @Log(title = "课程评分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NbCourseGrade nbCourseGrade)
    {
        return toAjax(nbCourseGradeService.updateNbCourseGrade(nbCourseGrade));
    }

    /**
     * 删除课程评分
     */
    @PreAuthorize("@ss.hasPermi('teach:course_grade:remove')")
    @Log(title = "课程评分", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(nbCourseGradeService.deleteNbCourseGradeByIds(ids));
    }
}
